package com.hlw.hr_man.serviceImpl;

import java.sql.Connection;
import java.util.List;

import com.hlw.hr_man.Model.SalaryModel;
import com.hlw.hr_man.dao.SalaryDao;
import com.hlw.hr_man.daoImpl.SalaryDaoImpl;
import com.hlw.hr_man.service.SalaryService;
import com.hlw.hr_man.util.JDBCUtil;

import net.sf.json.JSONObject;

public class SalaryServiceImpl implements SalaryService{
	JSONObject salarys = new JSONObject();
	SalaryDao saldao = new SalaryDaoImpl();
	
	//查看工资配置
	@Override
	public JSONObject getAllSalary(int start, int pageSize) {
		// TODO Auto-generated method stub
		salarys.put("total", saldao.getAllCout());
		salarys.put("rows", saldao.getAllSalary(start, pageSize));
		return salarys;
	}
	
	//添加工资配置
	@Override
	public int addSalary(SalaryModel sal) {
		// TODO Auto-generated method stub
		
		return saldao.addSalary(sal);
	}

	
	//修改员工工资配置
	@Override
	public int modifySalary(SalaryModel sal) {
		// TODO Auto-generated method stub
		
		return saldao.updateSalary(sal);
	}

	//通过月份查询
	@Override
	public JSONObject getSalaryByDate(String date, int start, int pageSize) {
		// TODO Auto-generated method stub
		salarys.put("total", saldao.findSalaryCountByDate(date));
		salarys.put("rows", saldao.findSalaryByDate(date, start, pageSize));
		return salarys;
	}

	//通过搜索查询
	@Override
	public JSONObject getSalaryByValue(String date,String value, int start, int pageSize) {
		// TODO Auto-generated method stub
		salarys.put("total", saldao.findSalaryCountByDateAndValue(date, value));
		salarys.put("rows", saldao.findSalaryByValue(date, value, start, pageSize));
		return salarys;
	}
	
	//查到所有的工资信息
	@Override
	public JSONObject findAllSalary(int start, int pageSize) {
		// TODO Auto-generated method stub
		salarys.put("total", saldao.findSalaryAllCount());
		salarys.put("rows", saldao.findAllSalary(start, pageSize));
		return salarys;
	}
	
	//通过日期找到工资信息
	@Override
	public JSONObject getSalaryByDept(String deptname, int start, int pageSize) {
		// TODO Auto-generated method stub
		salarys.put("total", saldao.findSalaryCountByDeptName(deptname));
		salarys.put("rows", saldao.findSalaryByDeptName(deptname, start, pageSize));
		return salarys;
	}
	
	//通过员工id和日期来找到缺勤记录
	@Override
	public JSONObject getSalaryAbsentByNoAndDate(int e_id, String sal_date,int start,int pageSize) {
		// TODO Auto-generated method stub
		JSONObject abts = new JSONObject();
		abts.put("total", saldao.getSalaryAbsentCountByNoAndDate(e_id, sal_date));
		abts.put("rows", saldao.getSalaryAbsentByNoAndDate(e_id, sal_date, start, pageSize));
		return abts;
	}
	
	//通过员工id和日期来找到加班记录
	@Override
	public JSONObject getSalaryOvertimeByNoAndDate(int e_id, String sal_date, int start, int pageSize) {
		// TODO Auto-generated method stub
		JSONObject ovts = new JSONObject();
		ovts.put("total", saldao.getSalaryOverTimeCountByNoAndDate(e_id, sal_date));
		ovts.put("rows", saldao.getSalaryOverTimeByNoAndDate(e_id, sal_date, start, pageSize));
		return ovts;
	}

}
